<div id='message-sucess'></div>
<div id="list-midia">
<?php
echo link_to(
                                        'Adicionar arquivo',
                                        url_for('midia/new?ref='.$reference.'&ref_value='.$ref_value),
                                        array(
                                                'id'        => 'file'
                                        )
                                );

?>
    <ul>
        <?php foreach($midia as $m){ ?>
        <div style="padding:5px; float:left;">
            <li id="show-img-buttons">
				<div align="right">
                    <?php

                    	echo link_to(
                        	image_tag("attach.png", array("rel" =>$m["id_arquivo"], "title" => 'Baixar arquivo - ' . $m['nome'])),
                            image_path("/uploads/".$m["arquivo"]),
                            array(
                            	'id' 	=> 'preview',
                                'title'	=> 'Baixar arquivo - ' . $m['nome'],
                                'rel'	=> 'midia_gallery',
                                'class' => 'icoDownload'
                            )
                        );
                    ?>


                        <?php
                                echo link_to(
                                        ' ',
                                        url_for('midia/edit?id_arquivo='.$m['id_arquivo'].'&ref='.$reference.'&ref_value='.$ref_value),
                                        array(
                                                'class'     => 'icoEditar',
                                                'id'        => 'file'
                                        )
                                );
                        ?>
                        <?php
                                echo link_to(
                                        ' ',
                                        url_for('midia/delete?id_arquivo='.$m['id_arquivo']),
                                        array(
                                                'class' => 'icoExcluir',
                                                'id'    => 'delete'
                                        )
                                );
                        ?>
                </div>
            </li>
        </div>
        <?php 	}        ?>
            <div style="clear:both;"></div>
    </ul>
</div>
<script type="text/javascript">
$(function()
{
    System.modaldata.onClick('file', 'dialog', {width: 600, height: 250, modal:true, title: 'Controle de arquivo'});
    System.formdata.remove('1');
    System.modaldata.openMidiaBox('midia_gallery', true);
});
</script>
